home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / g++1.68k / toplev.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-04-13  |  57.9 KB  |  2,319 lines

  1. /* Top level of GNU C compiler
  2.    Copyright (C) 1987, 1988, 1989 Free Software Foundation, Inc.
  3.  
  4. This file is part of GNU CC.
  5.  
  6. GNU CC is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 1, or (at your option)
  9. any later version.
  10.  
  11. GNU CC is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with GNU CC; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20.  
  21. /* This is the top level of cc1/c++.
  22.    It parses command args, opens files, invokes the various passes
  23.    in the proper order, and counts the time used by each.
  24.    Error messages and low-level interface to malloc also handled here.  */
  25.  
  26. #include "config.h"
  27. #include <stdio.h>
  28. #include <signal.h>
  29. #include <setjmp.h>
  30.  
  31. #include <sys/types.h>
  32. #include <sys/stat.h>
  33. #include <sys/file.h>
  34.  
  35. #ifdef NO_UNISTD_H
  36. #define SEEK_SET L_SET
  37. #define SEEK_CUR L_INCR
  38. #define SEEK_END L_XTND
  39. #else
  40. #include <unistd.h>
  41. #endif
  42.  
  43. #ifdef USG
  44. #include <sys/fcntl.h>
  45. #undef FLOAT
  46. #include <sys/param.h>
  47. /* This is for hpux.  It is a real screw.  They should change hpux.  */
  48. #undef FLOAT
  49. #include <sys/times.h>
  50. #include <time.h>   /* Correct for hpux at least.  Is it good on other USG?  */
  51. #undef FFS  /* Some systems define this in param.h.  */
  52. #else
  53. #ifndef VMS
  54. #include <sys/time.h>
  55. #include <sys/resource.h>
  56. #endif
  57. #endif
  58.  
  59. #include "input.h"
  60. #include "tree.h"
  61. #include "c-tree.h"
  62. #include "rtl.h"
  63. #include "flags.h"
  64.  
  65. #ifndef _bufsiz
  66. #define _bufsiz(p) ((p)->_bufsiz)
  67. #endif
  68.  
  69. /* Change by Bryan Boreham, Kewill, Sun Jul 23 14:41:26 1989.
  70.    Added some stuff for unexec-ing a part-done compilation. */
  71.  
  72. int been_here_before = 0;    /* Is this an unexec'd program? */
  73. int just_done_unexec = 0;    /* Is this the process that *was* unexec'd?  */
  74. char *dump_source_name;        /* Keep argv[0] for dumping. */
  75.  
  76. /* @@ Should there be a filename length limit?  */
  77. char previous_asm_file_name[128]; /* asm_file_name from the first run. */
  78.  
  79. extern int yydebug;
  80.  
  81. extern FILE *finput;
  82.  
  83. extern int reload_completed;
  84. extern int rtx_equal_function_value_matters;
  85.  
  86. extern void init_lex ();
  87. extern void init_decl_processing ();
  88. extern void init_tree ();
  89. extern void init_rtl ();
  90. extern void init_optabs ();
  91. extern void init_stmt ();
  92. extern void init_reg_sets ();
  93. extern void dump_flow_info ();
  94. extern void dump_local_alloc ();
  95.  
  96. void rest_of_decl_compilation ();
  97. void error ();
  98. void error_with_file_and_line ();
  99. void fancy_abort ();
  100. void set_target_switch ();
  101. void print_target_switch_defaults ();
  102. static char *decl_name ();
  103.  
  104. /* Bit flags that specify the machine subtype we are compiling for.
  105.    Bits are tested using macros TARGET_... defined in the tm-...h file
  106.    and set by `-m...' switches.  */
  107.  
  108. int target_flags;
  109.  
  110. /* Name of current original source file (what was input to cpp).
  111.    This comes from each #-command in the actual input.  */
  112.  
  113. char *input_filename;
  114.  
  115. /* Name of top-level original source file (what was input to cpp).
  116.    This comes from the #-command at the beginning of the actual input.
  117.    If there isn't any there, then this is the cc1 input file name.  */
  118.  
  119. char *main_input_filename;
  120.  
  121. /* Current line number in real source file.  */
  122.  
  123. int lineno;
  124.  
  125. /* Stack of currently pending input files.  */
  126.  
  127. struct file_stack *input_file_stack;
  128.  
  129. /* Incremented on each change to input_file_stack.  */
  130. int input_file_stack_tick;
  131.  
  132. /* FUNCTION_DECL for function now being parsed or compiled.  */
  133.  
  134. extern tree current_function_decl;
  135.  
  136. /* Name to use as base of names for dump output files.  */
  137.  
  138. char *dump_base_name;
  139.  
  140. /* Flags saying which kinds of debugging dump have been requested.  */
  141.  
  142. int rtl_dump = 0;
  143. int rtl_dump_and_exit = 0;
  144. int jump_opt_dump = 0;
  145. int cse_dump = 0;
  146. int loop_dump = 0;
  147. int flow_dump = 0;
  148. int combine_dump = 0;
  149. int local_reg_dump = 0;
  150. int global_reg_dump = 0;
  151. int jump2_opt_dump = 0;
  152. int dbr_sched_dump = 0;
  153.  
  154. /* 1 => write gdb debugging output (using symout.c).  -g0
  155.    2 => write dbx debugging output (using dbxout.c).  -G0  */
  156.  
  157. enum debugger write_symbols = NO_DEBUG;
  158.  
  159. /* Nonzero means can use our own extensions to DBX format.
  160.    Relevant only with write_symbols == DBX_DEBUG.  */
  161.  
  162. int use_gdb_dbx_extensions;
  163.  
  164. /* Nonzero means do optimizations.  -opt.  */
  165.  
  166. int optimize = 0;
  167.  
  168. /* Nonzero means `char' should be signed.  */
  169.  
  170. int flag_signed_char;
  171.  
  172. /* Nonzero means give an enum type only as many bytes as it needs.  */
  173.  
  174. int flag_short_enums;
  175.  
  176. /* Nonzero for -fcaller-saves: allocate values in regs that need to
  177.    be saved across function calls, if that produces overall better code.
  178.    Optional now, so people can test it.  */
  179.  
  180. #ifdef DEFAULT_CALLER_SAVES
  181. int flag_caller_saves = 1;
  182. #else
  183. int flag_caller_saves = 0;
  184. #endif
  185.  
  186. /* Nonzero for -fpcc-struct-return: return values the same way PCC does.  */
  187.  
  188. int flag_pcc_struct_return = 0;
  189.  
  190. /* Nonzero for -fforce-mem: load memory value into a register
  191.    before arithmetic on it.  This makes better cse but slower compilation.  */
  192.  
  193. int flag_force_mem = 0;
  194.  
  195. /* Nonzero for -fforce-addr: load memory address into a register before
  196.    reference to memory.  This makes better cse but slower compilation.  */
  197.  
  198. int flag_force_addr = 0;
  199.  
  200. /* Nonzero for -fdefer-pop: don't pop args after each function call;
  201.    instead save them up to pop many calls' args with one insns.  */
  202.  
  203. int flag_defer_pop = 1;
  204.  
  205. /* Nonzero for -ffloat-store: don't allocate floats and doubles
  206.    in extended-precision registers.  */
  207.  
  208. int flag_float_store = 0;
  209.  
  210. /* Nonzero for -fcombine-regs:
  211.    allow instruction combiner to combine an insn
  212.    that just copies one reg to another.  */
  213.  
  214. int flag_combine_regs = 0;
  215.  
  216. /* Nonzero for -fcse-follow-jumps:
  217.    have cse follow jumps to do a more extensive job.  */
  218.  
  219. int flag_cse_follow_jumps;
  220.  
  221. /* Nonzero enables strength-reduction in loop.c.  */
  222.  
  223. int flag_strength_reduce = 0;
  224.  
  225. /* Nonzero for -fwritable-strings:
  226.    store string constants in data segment and don't uniquize them.  */
  227.  
  228. int flag_writable_strings = 0;
  229.  
  230. /* Nonzero means don't put addresses of constant functions in registers.
  231.    Used for compiling the Unix kernel, where strange substitutions are
  232.    done on the assembly output.  */
  233.  
  234. int flag_no_function_cse = 0;
  235.  
  236. /* Nonzero for -fomit-frame-pointer:
  237.    don't make a frame pointer in simple functions that don't require one.  */
  238.  
  239. int flag_omit_frame_pointer = 0;
  240.  
  241. /* Nonzero to inhibit use of define_optimization peephole opts.  */
  242.  
  243. int flag_no_peephole = 0;
  244.  
  245. /* Nonzero means all references through pointers are volatile.  */
  246.  
  247. int flag_volatile;
  248.  
  249. /* Nonzero means just do syntax checking; don't output anything.  */
  250.  
  251. int flag_syntax_only = 0;
  252.  
  253. /* Nonzero means do stupid register allocation.
  254.    Currently, this is 1 if `optimize' is 0.  */
  255.  
  256. int obey_regdecls = 0;
  257.  
  258. /* Don't print functions as they are compiled and don't print
  259.    times taken by the various passes.  -quiet.  */
  260.  
  261. int quiet_flag = 0;
  262.  
  263. /* Don't print warning messages.  -w.  */
  264.  
  265. int inhibit_warnings = 0;
  266.  
  267. /* Do print extra warnings (such as for uninitialized variables).  -W.  */
  268.  
  269. int extra_warnings = 0;
  270.  
  271. /* Nonzero to warn about unused local variables.  */
  272.  
  273. int warn_unused;
  274.  
  275. /* Nonzero means warn about all declarations which shadow others.   */
  276.  
  277. int warn_shadow;
  278.  
  279. /* Warn if a switch on an enum fails to have a case for every enum value.  */
  280.  
  281. int warn_switch;
  282.  
  283. /* Warn if a type conversion is done that might have confusing results.  */
  284.  
  285. int warn_conversion;
  286.  
  287. /* Nonzero means warn about any identifiers that match in the first N
  288.    characters.  The value N is in `id_clash_len'.  */
  289.  
  290. int warn_id_clash;
  291. int id_clash_len;
  292.  
  293. /* Number of error messages and warning messages so far.  */
  294.  
  295. int errorcount = 0;
  296. int warningcount = 0;
  297. int sorrycount = 0;
  298.  
  299. /* Pointer to function to compute the name to use to print a declaration.  */
  300.  
  301. char *(*decl_printable_name) ();
  302.  
  303. /* Pointer to function to compute rtl for a language-specific tree code.  */
  304.  
  305. struct rtx_def *(*lang_expand_expr) ();
  306.  
  307. /* Name of program invoked, sans directories.  */
  308.  
  309. char *progname;
  310.  
  311. /* Nonzero if generating code to do profiling.  */
  312.  
  313. int profile_flag = 0;
  314.  
  315. /* Nonzero if generating code to do profiling on a line-by-line basis.  */
  316.  
  317. int profile_block_flag;
  318.  
  319. /* Nonzero for -pedantic switch: warn about anything
  320.    that standard spec forbids.  */
  321.  
  322. int pedantic = 0;
  323.  
  324. /* Nonzero for -finline-functions: ok to inline functions that look like
  325.    good inline candidates.  */
  326.  
  327. int flag_inline_functions;
  328.  
  329. /* Nonzero for -fkeep-inline-functions: even if we make a function
  330.    go inline everywhere, keep its defintion around for debugging
  331.    purposes.  */
  332.  
  333. int flag_keep_inline_functions;
  334.  
  335. /* Nonzero means make the text shared if supported.  */
  336.  
  337. int flag_shared_data;
  338.  
  339. /* Nonzero means schedule into delayed branch slots if supported.  */
  340.  
  341. int flag_delayed_branch;
  342.  
  343. /* Copy of arguments to main.  */
  344. int save_argc;
  345. char **save_argv;
  346.  
  347. /* Nonzero means schedule instructions within basic blocks.  */
  348.  
  349. int flag_schedule_insns = 0;
  350.  
  351. /* Name for output file of assembly code, specified with -o.  */
  352.  
  353. char *asm_file_name;
  354.  
  355. #if 0
  356. /* Name for output file of GDB symbol segment, specified with -symout.  */
  357.  
  358. char *sym_file_name;
  359. #endif /* 0 */
  360.  
  361. /* Table of language-independent -f options.
  362.    STRING is the option name.  VARIABLE is the address of the variable.
  363.    ON_VALUE is the value to store in VARIABLE
  364.     if `-fSTRING' is seen as an option.
  365.    (If `-fno-STRING' is seen as an option, the opposite value is stored.)  */
  366.  
  367. static struct { char *string; int *variable; int on_value;} f_options[] =
  368. {
  369.   {"float-store", &flag_float_store, 1},
  370.   {"volatile", &flag_volatile, 1},
  371.   {"defer-pop", &flag_defer_pop, 1},
  372.   {"omit-frame-pointer", &flag_omit_frame_pointer, 1},
  373.   {"cse-follow-jumps", &flag_cse_follow_jumps, 1},
  374.   {"strength-reduce", &flag_strength_reduce, 1},
  375.   {"writable-strings", &flag_writable_strings, 1},
  376.   {"peephole", &flag_no_peephole, 0},
  377.   {"force-mem", &flag_force_mem, 1},
  378.   {"force-addr", &flag_force_addr, 1},
  379.   {"combine-regs", &flag_combine_regs, 1},
  380.   {"function-cse", &flag_no_function_cse, 0},
  381.   {"inline-functions", &flag_inline_functions, 1},
  382.   {"keep-inline-functions", &flag_keep_inline_functions, 1},
  383.   {"syntax-only", &flag_syntax_only, 1},
  384.   {"shared-data", &flag_shared_data, 1},
  385.   {"caller-saves", &flag_caller_saves, 1},
  386.   {"pcc-struct-return", &flag_pcc_struct_return, 1},
  387.   {"delayed-branch", &flag_delayed_branch, 1},
  388.   {"schedule-insns", &flag_schedule_insns, 1}
  389. };
  390.  
  391. /* Output files for assembler code (real compiler output)
  392.    and debugging dumps.  */
  393.  
  394. FILE *asm_out_file;
  395. FILE *rtl_dump_file;
  396. FILE *jump_opt_dump_file;
  397. FILE *cse_dump_file;
  398. FILE *loop_dump_file;
  399. FILE *flow_dump_file;
  400. FILE *combine_dump_file;
  401. FILE *local_reg_dump_file;
  402. FILE *global_reg_dump_file;
  403. FILE *jump2_opt_dump_file;
  404. FILE *dbr_sched_dump_file;
  405.  
  406. /* Time accumulators, to count the total time spent in various passes.  */
  407.  
  408. int parse_time;
  409. int varconst_time;
  410. int integration_time;
  411. int jump_time;
  412. int cse_time;
  413. int loop_time;
  414. int flow_time;
  415. int combine_time;
  416. int local_alloc_time;
  417. int global_alloc_time;
  418. int dbr_sched_time;
  419. int shorten_branch_time;
  420. int final_time;
  421. int symout_time;
  422. int dump_time;
  423.  
  424. /* Return time used so far, in microseconds.  */
  425.  
  426. int
  427. gettime ()
  428. {
  429. #ifdef USG
  430.   struct tms tms;
  431. #else
  432. #ifndef VMS
  433.   struct rusage rusage;
  434. #else /* VMS */
  435.   struct
  436.     {
  437.       int proc_user_time;
  438.       int proc_system_time;
  439.       int child_user_time;
  440.       int child_system_time;
  441.     } vms_times;
  442. #endif
  443. #endif
  444.  
  445.   if (quiet_flag)
  446.     return 0;
  447.  
  448. #ifdef USG
  449.   times (&tms);
  450.   return (tms.tms_utime + tms.tms_stime) * (1000000 / HZ);
  451. #else
  452. #ifndef VMS
  453.   getrusage (0, &rusage);
  454.   return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec
  455.       + rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec);
  456. #else /* VMS */
  457.   times (&vms_times);
  458.   return (vms_times.proc_user_time + vms_times.proc_system_time) * 10000;
  459. #endif
  460. #endif
  461. }
  462.  
  463. #define TIMEVAR(VAR, BODY)    \
  464. do { int otime = gettime (); BODY; VAR += gettime () - otime; } while (0)
  465.  
  466. void
  467. print_time (str, total)
  468.      char *str;
  469.      int total;
  470. {
  471.   fprintf (stderr,
  472.        "time in %s: %d.%06d\n",
  473.        str, total / 1000000, total % 1000000);
  474. }
  475.  
  476. /* Count an error or warning.  Return 1 if the message should be printed.  */
  477.  
  478. int
  479. count_error (warningp)
  480.      int warningp;
  481. {
  482.   if (warningp && inhibit_warnings)
  483.     return 0;
  484.  
  485.   if (warningp)
  486.     warningcount++;
  487.   else
  488.     errorcount++;
  489.  
  490.   return 1;
  491. }
  492.  
  493. /* Print a fatal error message.  NAME is the text.
  494.    Also include a system error message based on `errno'.  */
  495.  
  496. void
  497. pfatal_with_name (name)
  498.      char *name;
  499. {
  500.   fprintf (stderr, "%s: ", progname);
  501.   perror (name);
  502.   exit (35);
  503. }
  504.  
  505. void
  506. fatal_io_error (name)
  507.      char *name;
  508. {
  509.   fprintf (stderr, "%s: %s: I/O error\n", progname, name);
  510.   exit (35);
  511. }
  512.  
  513. void
  514. fatal (s, v)
  515.      char *s;
  516.      int v;
  517. {
  518.   error (s, v);
  519.   exit (34);
  520. }
  521.  
  522. /* Called from insn-extract to give a better error message when we
  523.    don't have an insn to match what we are looking for, rather
  524.    than just calling abort().  */
  525.  
  526. void
  527. fatal_insn_not_found (insn)
  528.      rtx insn;
  529. {
  530.   error ("The following insn was not recognizable:", 0);
  531.   debug_rtx (insn);
  532.   abort ();
  533. }
  534.  
  535. /* This is the default decl_printable_name function.  */
  536.  
  537. static char *
  538. decl_name (decl)
  539.      tree decl;
  540. {
  541.   return IDENTIFIER_POINTER (DECL_NAME (decl));
  542. }
  543.  
  544. static int need_error_newline;
  545.  
  546. /* Function of last error message;
  547.    more generally, function such that if next error message is in it
  548.    then we don't have to mention the function name.  */
  549. static tree last_error_function = NULL;
  550.  
  551. /* Used to detect when input_file_stack has changed since last described.  */
  552. static int last_error_tick;
  553.  
  554. /* Called when the start of a function definition is parsed,
  555.    this function prints on stderr the name of the function.  */
  556.  
  557. void
  558. announce_function (decl)
  559.      tree decl;
  560. {
  561.   if (! quiet_flag)
  562.     {
  563.       if (rtl_dump_and_exit)
  564.     fprintf (stderr, "%s ", IDENTIFIER_POINTER (DECL_NAME (decl)));
  565.       else
  566.     fprintf (stderr, " %s", (*decl_printable_name) (decl));
  567.       fflush (stderr);
  568.       need_error_newline = 1;
  569.       last_error_function = current_function_decl;
  570.     }
  571. }
  572.  
  573. /* Prints out, if necessary, the name of the current function
  574.    which caused an error.  Called from all error and warning functions.  */
  575.  
  576. void
  577. report_error_function (file)
  578.      char *file;
  579. {
  580.   struct file_stack *p;
  581.  
  582.   if (need_error_newline)
  583.     {
  584.       fprintf (stderr, "\n");
  585.       need_error_newline = 0;
  586.     }
  587.  
  588.   if (last_error_function != current_function_decl)
  589.     {
  590.       if (file)
  591.     fprintf (stderr, "%s: ", file);
  592.  
  593.       if (current_function_decl == NULL)
  594.     fprintf (stderr, "At top level:\n");
  595.       else if (TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE)
  596.     fprintf (stderr, "In method %s:\n",
  597.          (*decl_printable_name) (current_function_decl));
  598.       else
  599.     fprintf (stderr, "In function %s:\n",
  600.          (*decl_printable_name) (current_function_decl));
  601.  
  602.       last_error_function = current_function_decl;
  603.     }
  604.   if (input_file_stack && input_file_stack->next != 0
  605.       && input_file_stack_tick != last_error_tick)
  606.     {
  607.       fprintf (stderr, "In file included");
  608.       for (p = input_file_stack->next; p; p = p->next)
  609.     {
  610.       fprintf (stderr, " from %s:%d", p->name, p->line);
  611.       if (p->next)
  612.         fprintf (stderr, ",");
  613.     }
  614.       fprintf (stderr, ":\n");
  615.       last_error_tick = input_file_stack_tick;
  616.     }
  617. }
  618.  
  619. /* Report an error at the current line number.
  620.    S and V are a string and an arg for `printf'.  */
  621.  
  622. void
  623. error (s, v, v2)
  624.      char *s;
  625.      int v;            /* @@also used as pointer */
  626.      int v2;            /* @@also used as pointer */
  627. {
  628.   error_with_file_and_line (input_filename, lineno, s, v, v2);
  629. }
  630.  
  631. /* Report an error at line LINE of file FILE.
  632.    S and V are a string and an arg for `printf'.  */
  633.  
  634. void
  635. error_with_file_and_line (file, line, s, v, v2)
  636.      char *file;
  637.      int line;
  638.      char *s;
  639.      int v;
  640.      int v2;
  641. {
  642.   count_error (0);
  643.  
  644.   report_error_function (file);
  645.  
  646.   if (file)
  647.     fprintf (stderr, "%s:%d: ", file, line);
  648.   else
  649.     fprintf (stderr, "%s: ", progname);
  650.   fprintf (stderr, s, v, v2);
  651.   fprintf (stderr, "\n");
  652. }
  653.  
  654. /* Report an error at the declaration DECL.
  655.    S and V are a string and an arg which uses %s to substitute the declaration name.  */
  656.  
  657. void
  658. error_with_decl (decl, s, v)
  659.      tree decl;
  660.      char *s;
  661.      int v;
  662. {
  663.   count_error (0);
  664.  
  665.   report_error_function (DECL_SOURCE_FILE (decl));
  666.  
  667.   if (TREE_CODE (decl) == PARM_DECL)
  668.     fprintf (stderr, "%s:%d: ",
  669.          DECL_SOURCE_FILE (DECL_CONTEXT (decl)),
  670.          DECL_SOURCE_LINE (DECL_CONTEXT (decl)));
  671.   else
  672.     fprintf (stderr, "%s:%d: ",
  673.          DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
  674.  
  675.   if (DECL_NAME (decl))
  676.     fprintf (stderr, s, (*decl_printable_name) (decl), v);
  677.   else
  678.     fprintf (stderr, s, "((anonymous))", v);
  679.   fprintf (stderr, "\n");
  680. }
  681.  
  682. /* Report an error at the line number of the insn INSN.
  683.    S and V are a string and an arg for `printf'.
  684.    This is used only when INSN is an `asm' with operands,
  685.    and each ASM_OPERANDS records its own source file and line.  */
  686.  
  687. void
  688. error_for_asm (insn, s, v, v2)
  689.      rtx insn;
  690.      char *s;
  691.      int v;            /* @@also used as pointer */
  692.      int v2;            /* @@also used as pointer */
  693. {
  694.   char *filename;
  695.   int line;
  696.   rtx body = PATTERN (insn);
  697.   rtx asmop;
  698.  
  699.   /* Find the (or one of the) ASM_OPERANDS in the insn.  */
  700.   if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS)
  701.     asmop = SET_SRC (body);
  702.   else if (GET_CODE (body) == ASM_OPERANDS)
  703.     asmop = body;
  704.   else if (GET_CODE (body) == PARALLEL
  705.        && GET_CODE (XVECEXP (body, 0, 0)) == SET)
  706.     asmop = SET_SRC (XVECEXP (body, 0, 0));
  707.   else if (GET_CODE (body) == PARALLEL
  708.        && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS)
  709.     asmop = XVECEXP (body, 0, 0);
  710.  
  711.   filename = ASM_OPERANDS_SOURCE_FILE (asmop);
  712.   line = ASM_OPERANDS_SOURCE_LINE (asmop);
  713.  
  714.   error_with_file_and_line (filename, line, s, v, v2);
  715. }
  716.  
  717. /* Report a warning at line LINE.
  718.    S and V are a string and an arg for `printf'.  */
  719.  
  720. void
  721. warning_with_file_and_line (file, line, s, v, v2)
  722.      char *file;
  723.      int line;
  724.      char *s;
  725.      int v;
  726.      int v2;
  727. {
  728.   if (count_error (1) == 0)
  729.     return;
  730.  
  731.   report_error_function (file);
  732.  
  733.   if (file)
  734.     fprintf (stderr, "%s:%d: ", file, line);
  735.   else
  736.     fprintf (stderr, "%s: ", progname);
  737.  
  738.   fprintf (stderr, "warning: ");
  739.   fprintf (stderr, s, v, v2);
  740.   fprintf (stderr, "\n");
  741. }
  742.  
  743. /* Report a warning at the current line number.
  744.    S and V are a string and an arg for `printf'.  */
  745.  
  746. void
  747. warning (s, v, v2)
  748.      char *s;
  749.      int v;            /* @@also used as pointer */
  750.      int v2;
  751. {
  752.   warning_with_file_and_line (input_filename, lineno, s, v, v2);
  753. }
  754.  
  755. /* Report a warning at the declaration DECL.
  756.    S is string which uses %s to substitute the declaration name.
  757.    V is a second parameter that S can refer to.  */
  758.  
  759. void
  760. warning_with_decl (decl, s, v)
  761.      tree decl;
  762.      char *s;
  763.      int v;
  764. {
  765.   if (count_error (1) == 0)
  766.     return;
  767.  
  768.   report_error_function (DECL_SOURCE_FILE (decl));
  769.  
  770.   if (TREE_CODE (decl) == PARM_DECL)
  771.     fprintf (stderr, "%s:%d: ",
  772.          DECL_SOURCE_FILE (DECL_CONTEXT (decl)),
  773.          DECL_SOURCE_LINE (DECL_CONTEXT (decl)));
  774.   else
  775.     fprintf (stderr, "%s:%d: ",
  776.          DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
  777.  
  778.   fprintf (stderr, "warning: ");
  779.   if (DECL_NAME (decl))
  780.     fprintf (stderr, s, (*decl_printable_name) (decl), v);
  781.   else
  782.     fprintf (stderr, s, "((anonymous))", v);
  783.   fprintf (stderr, "\n");
  784. }
  785.  
  786. /* Apologize for not implementing some feature.
  787.    S, V, and V2 are a string and args for `printf'.  */
  788.  
  789. void
  790. sorry (s, v, v2)
  791.      char *s;
  792.      int v, v2;
  793. {
  794.   sorrycount++;
  795.   if (input_filename)
  796.     fprintf (stderr, "%s:%d: ", input_filename, lineno);
  797.   else
  798.     fprintf (stderr, "%s: ", progname);
  799.  
  800.   fprintf (stderr, "sorry, not implemented: ");
  801.   fprintf (stderr, s, v, v2);
  802.   fprintf (stderr, "\n");
  803. }
  804.  
  805. /* Apologize for not implementing some feature, then quit.
  806.    S, V, and V2 are a string and args for `printf'.  */
  807.  
  808. void
  809. really_sorry (s, v, v2)
  810.      char *s;
  811.      int v, v2;
  812. {
  813.   if (input_filename)
  814.     fprintf (stderr, "%s:%d: ", input_filename, lineno);
  815.   else
  816.     fprintf (stderr, "c++: ");
  817.  
  818.   fprintf (stderr, "sorry, not implemented: ");
  819.   fprintf (stderr, s, v, v2);
  820.   fatal (" (fatal)\n");
  821. }
  822.  
  823. /* More 'friendly' abort that prints the line and file.
  824.    config.h can #define abort fancy_abort if you like that sort of thing.  */
  825.  
  826. void
  827. fancy_abort ()
  828. {
  829.   fatal ("Internal gcc abort.");
  830. }
  831.  
  832. /* When `malloc.c' is compiled with `rcheck' defined,
  833.    it calls this function to report clobberage.  */
  834.  
  835. void
  836. botch (s)
  837. {
  838.   abort ();
  839. }
  840.  
  841. /* Same as `malloc' but report error if no memory available.  */
  842.  
  843. int
  844. xmalloc (size)
  845.      unsigned size;
  846. {
  847.   register int value = (int) malloc (size);
  848.   if (value == 0)
  849.     fatal ("Virtual memory exhausted.");
  850.   return value;
  851. }
  852.  
  853. /* Same as `realloc' but report error if no memory available.  */
  854.  
  855. int
  856. xrealloc (ptr, size)
  857.      char *ptr;
  858.      int size;
  859. {
  860.   int result = realloc (ptr, size);
  861.   if (!result)
  862.     fatal ("Virtual memory exhausted.");
  863.   return result;
  864. }
  865.  
  866. /* Return the logarithm of X, base 2, considering X unsigned,
  867.    if X is a power of 2.  Otherwise, returns -1.  */
  868.  
  869. int
  870. exact_log2 (x)
  871.      register unsigned int x;
  872. {
  873.   register int log = 0;
  874.   /* Test for 0 or a power of 2.  */
  875.   if (x == 0 || x != (x & -x))
  876.     return -1;
  877.   while ((x >>= 1) != 0)
  878.     log++;
  879.   return log;
  880. }
  881.  
  882. /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
  883.    If X is 0, return -1.  */
  884.  
  885. int
  886. floor_log2 (x)
  887.      register unsigned int x;
  888. {
  889.   register int log = -1;
  890.   while (x != 0)
  891.     log++,
  892.     x >>= 1;
  893.   return log;
  894. }
  895.  
  896. int float_handled;
  897. jmp_buf float_handler;
  898. jmp_buf toplevel;
  899.  
  900. /* Specify where to longjmp to when a floating arithmetic error happens.
  901.    If HANDLER is 0, it means don't handle the errors any more.  */
  902.  
  903. void
  904. set_float_handler (handler)
  905.      jmp_buf handler;
  906. {
  907.   float_handled = (handler != 0);
  908.   if (handler)
  909.     bcopy (handler, float_handler, sizeof (float_handler));
  910. }
  911.  
  912. /* Signals actually come here.  */
  913.  
  914. static void
  915. float_signal ()
  916. {
  917.   if (float_handled == 0)
  918.     abort ();
  919.   float_handled = 0;
  920.   longjmp (float_handler, 1);
  921. }
  922.  
  923. /* Handler for SIGPIPE.  */
  924.  
  925. static void
  926. pipe_closed ()
  927. {
  928.   fatal ("output pipe has been closed");
  929. }
  930.  
  931. /* Compile an entire file of output from cpp, named NAME.
  932.    Write a file of assembly output and various debugging dumps.  */
  933.  
  934. static void
  935. compile_file (name)
  936.      char *name;
  937. {
  938.   tree globals;
  939.   int start_time;
  940.   int dump_base_name_length;
  941.  
  942.   int name_specified = name != 0;
  943.  
  944.   if (dump_base_name == 0 || been_here_before)
  945.     dump_base_name = name ? name : "gccdump";
  946.   dump_base_name_length = strlen (dump_base_name);
  947.  
  948.   parse_time = 0;
  949.   varconst_time = 0;
  950.   integration_time = 0;
  951.   jump_time = 0;
  952.   cse_time = 0;
  953.   loop_time = 0;
  954.   flow_time = 0;
  955.   combine_time = 0;
  956.   local_alloc_time = 0;
  957.   global_alloc_time = 0;
  958.   dbr_sched_time = 0;
  959.   shorten_branch_time = 0;
  960.   final_time = 0;
  961.   symout_time = 0;
  962.   dump_time = 0;
  963.  
  964.   /* Open input file.  */
  965.  
  966.   if (name == 0 || !strcmp (name, "-"))
  967.     {
  968.       finput = stdin;
  969.       name = "stdin";
  970.     }
  971.   else
  972.     finput = fopen (name, "r");
  973.   if (finput == 0)
  974.     pfatal_with_name (name);
  975.  
  976.   /* Initialize data in various passes,  
  977.      checking if this is an unexec'd program - bryan@kewill.uucp.  */
  978.  
  979.   if (!been_here_before)
  980.     {
  981.       init_tree ();
  982.       init_lex ();
  983.       init_rtl ();
  984.       init_emit_once ();
  985.       init_decl_processing ();
  986.       init_optabs ();
  987.       init_stmt ();
  988.     }
  989.   else
  990.     {
  991.       extern void reinit_lex_for_unexec ();
  992.       reinit_lex_for_unexec ();
  993.       reinit_search_statistics ();
  994.       main_input_filename = 0;
  995.     }
  996.  
  997.   /* If rtl dump desired, open the output file.  */
  998.   if (rtl_dump)
  999.     {
  1000.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
  1001.       strcpy (dumpname, dump_base_name);
  1002.       strcat (dumpname, ".rtl");
  1003.       rtl_dump_file = fopen (dumpname, "w");
  1004.       if (rtl_dump_file == 0)
  1005.     pfatal_with_name (dumpname);
  1006.     }
  1007.  
  1008.   /* If jump_opt dump desired, open the output file.  */
  1009.   if (jump_opt_dump)
  1010.     {
  1011.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
  1012.       strcpy (dumpname, dump_base_name);
  1013.       strcat (dumpname, ".jump");
  1014.       jump_opt_dump_file = fopen (dumpname, "w");
  1015.       if (jump_opt_dump_file == 0)
  1016.     pfatal_with_name (dumpname);
  1017.     }
  1018.  
  1019.   /* If cse dump desired, open the output file.  */
  1020.   if (cse_dump)
  1021.     {
  1022.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
  1023.       strcpy (dumpname, dump_base_name);
  1024.       strcat (dumpname, ".cse");
  1025.       cse_dump_file = fopen (dumpname, "w");
  1026.       if (cse_dump_file == 0)
  1027.     pfatal_with_name (dumpname);
  1028.     }
  1029.  
  1030.   /* If loop dump desired, open the output file.  */
  1031.   if (loop_dump)
  1032.     {
  1033.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
  1034.       strcpy (dumpname, dump_base_name);
  1035.       strcat (dumpname, ".loop");
  1036.       loop_dump_file = fopen (dumpname, "w");
  1037.       if (loop_dump_file == 0)
  1038.     pfatal_with_name (dumpname);
  1039.     }
  1040.  
  1041.   /* If flow dump desired, open the output file.  */
  1042.   if (flow_dump)
  1043.     {
  1044.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
  1045.       strcpy (dumpname, dump_base_name);
  1046.       strcat (dumpname, ".flow");
  1047.       flow_dump_file = fopen (dumpname, "w");
  1048.       if (flow_dump_file == 0)
  1049.     pfatal_with_name (dumpname);
  1050.     }
  1051.  
  1052.   /* If combine dump desired, open the output file.  */
  1053.   if (combine_dump)
  1054.     {
  1055.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 10);
  1056.       strcpy (dumpname, dump_base_name);
  1057.       strcat (dumpname, ".combine");
  1058.       combine_dump_file = fopen (dumpname, "w");
  1059.       if (combine_dump_file == 0)
  1060.     pfatal_with_name (dumpname);
  1061.     }
  1062.  
  1063.   /* If local_reg dump desired, open the output file.  */
  1064.   if (local_reg_dump)
  1065.     {
  1066.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
  1067.       strcpy (dumpname, dump_base_name);
  1068.       strcat (dumpname, ".lreg");
  1069.       local_reg_dump_file = fopen (dumpname, "w");
  1070.       if (local_reg_dump_file == 0)
  1071.     pfatal_with_name (dumpname);
  1072.     }
  1073.  
  1074.   /* If global_reg dump desired, open the output file.  */
  1075.   if (global_reg_dump)
  1076.     {
  1077.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
  1078.       strcpy (dumpname, dump_base_name);
  1079.       strcat (dumpname, ".greg");
  1080.       global_reg_dump_file = fopen (dumpname, "w");
  1081.       if (global_reg_dump_file == 0)
  1082.     pfatal_with_name (dumpname);
  1083.     }
  1084.  
  1085.   /* If jump2_opt dump desired, open the output file.  */
  1086.   if (jump2_opt_dump)
  1087.     {
  1088.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 7);
  1089.       strcpy (dumpname, dump_base_name);
  1090.       strcat (dumpname, ".jump2");
  1091.       jump2_opt_dump_file = fopen (dumpname, "w");
  1092.       if (jump2_opt_dump_file == 0)
  1093.     pfatal_with_name (dumpname);
  1094.     }
  1095.  
  1096.   /* If dbr_sched dump desired, open the output file.  */
  1097.   if (dbr_sched_dump)
  1098.     {
  1099.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 7);
  1100.       strcpy (dumpname, dump_base_name);
  1101.       strcat (dumpname, ".dbr");
  1102.       dbr_sched_dump_file = fopen (dumpname, "w");
  1103.       if (dbr_sched_dump_file == 0)
  1104.     pfatal_with_name (dumpname);
  1105.     }
  1106.  
  1107.   /* Open assembler code output file.  */
  1108.  
  1109.   if (! name_specified && asm_file_name == 0)
  1110.     asm_out_file = stdout;
  1111.   else
  1112.     {
  1113.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
  1114.       int len = strlen (dump_base_name);
  1115.       strcpy (dumpname, dump_base_name);
  1116.       if (len > 2 && ! strcmp (".c", dumpname + len - 2))
  1117.     dumpname[len - 2] = 0;
  1118.       else if (len > 2 && ! strcmp (".i", dumpname + len - 2))
  1119.     dumpname[len - 2] = 0;
  1120.       else if (len > 3 && ! strcmp (".co", dumpname + len - 3))
  1121.     dumpname[len - 3] = 0;
  1122.       strcat (dumpname, ".s");
  1123.       if (asm_file_name == 0)
  1124.     {
  1125.       asm_file_name = (char *) malloc (strlen (dumpname) + 1);
  1126.       strcpy (asm_file_name, dumpname);
  1127.     }
  1128.       if (!strcmp (asm_file_name, "-"))
  1129.     asm_out_file = stdout;
  1130.       else
  1131.     asm_out_file = fopen (asm_file_name, "w");
  1132.       if (asm_out_file == 0)
  1133.     pfatal_with_name (asm_file_name);
  1134.     }
  1135.  
  1136.   input_filename = name;
  1137.  
  1138.   /* the beginning of the file is a new line; check for # */
  1139.   /* With luck, we discover the real source file's name from that
  1140.      and put it in input_filename.  */
  1141.   ungetc (check_newline (), finput);
  1142.  
  1143.   /* If the input doesn't start with a #line, use the input name
  1144.      as the official input file name.  */
  1145.   if (main_input_filename == 0)
  1146.     main_input_filename = name;
  1147.  
  1148.   /* Put an entry on the input file stack for the main input file.  */
  1149.   input_file_stack
  1150.     = (struct file_stack *) xmalloc (sizeof (struct file_stack));
  1151.   input_file_stack->next = 0;
  1152.   input_file_stack->name = input_filename;
  1153.  
  1154.   if (!been_here_before)
  1155.     {
  1156.       ASM_FILE_START (asm_out_file);
  1157.  
  1158.       /* Output something to inform GDB that this compilation was by GCC.  */
  1159. #ifndef ASM_IDENTIFY_GCC
  1160.       fprintf (asm_out_file, "gcc_compiled.:\n");
  1161. #else
  1162.       ASM_IDENTIFY_GCC (asm_out_file);
  1163. #endif
  1164.  
  1165.     }
  1166.   else
  1167.     {
  1168.       /* Copy what we output during the first run into this asm file. */
  1169.       FILE *prev_file;
  1170.       int c;
  1171.       prev_file = fopen (previous_asm_file_name, "r");
  1172.       if (prev_file == 0)
  1173.     pfatal_with_name (previous_asm_file_name);
  1174. #if !defined(VMS) && !defined(sprite)
  1175.       if (_bufsiz(asm_out_file) != _bufsiz(prev_file))
  1176. #endif
  1177.     {
  1178.       while ((c = getc (prev_file)) != EOF)
  1179.         putc (c, asm_out_file);
  1180.     }
  1181. #if !defined(VMS) && !defined(sprite)
  1182.       else
  1183.     {
  1184.       /* Copy quickly.  */
  1185.       int dummy, size;
  1186.  
  1187.       fwrite (&dummy, 1, 1, asm_out_file);
  1188.       asm_out_file->_ptr = asm_out_file->_base;
  1189.       asm_out_file->_cnt = _bufsiz(asm_out_file);
  1190.       do
  1191.         {
  1192.           size = fread (asm_out_file->_base, 1, _bufsiz(asm_out_file), prev_file);
  1193.           asm_out_file->_ptr += size;
  1194.           asm_out_file->_cnt -= size;
  1195.           fflush (asm_out_file);
  1196.         }
  1197.       while (size == _bufsiz(asm_out_file));
  1198.     }
  1199. #endif
  1200.       fclose (prev_file);
  1201.     }
  1202.  
  1203. #ifdef 0  /* This mode is discontinued.  */
  1204.   /* If GDB symbol table desired, open the GDB symbol output file.  */
  1205.   if (write_symbols == GDB_DEBUG)
  1206.     {
  1207.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
  1208.       int len = strlen (dump_base_name);
  1209.       strcpy (dumpname, dump_base_name);
  1210.       if (len > 2 && ! strcmp (".c", dumpname + len - 2))
  1211.     dumpname[len - 2] = 0;
  1212.       else if (len > 2 && ! strcmp (".i", dumpname + len - 2))
  1213.     dumpname[len - 2] = 0;
  1214.       else if (len > 3 && ! strcmp (".co", dumpname + len - 3))
  1215.     dumpname[len - 3] = 0;
  1216.       strcat (dumpname, ".sym");
  1217.       if (sym_file_name == 0)
  1218.     sym_file_name = dumpname;
  1219.       symout_init (sym_file_name, asm_out_file, main_input_filename);
  1220.     }
  1221. #endif /* 0 */
  1222.  
  1223.   /* If dbx symbol table desired, initialize writing it
  1224.      and output the predefined types.  */
  1225. #ifdef DBX_DEBUGGING_INFO
  1226.   if (write_symbols == DBX_DEBUG)
  1227.     {
  1228.       if (!been_here_before) 
  1229.     dbxout_init (asm_out_file, main_input_filename);
  1230.       else
  1231.     {
  1232.       extern void re_init_dbxout_for_unexec ();
  1233.       re_init_dbxout_for_unexec (asm_out_file, main_input_filename);
  1234.     }
  1235.     }
  1236. #endif
  1237. #ifdef SDB_DEBUGGING_INFO
  1238.   if (write_symbols == SDB_DEBUG)
  1239.     sdbout_init (asm_out_file, main_input_filename);
  1240. #endif
  1241.  
  1242.   /* Initialize yet another pass.  */
  1243.  
  1244.   if (!been_here_before)
  1245.     init_final (main_input_filename);
  1246.  
  1247.   start_time = gettime ();
  1248.  
  1249.   /* Call the parser, which parses the entire file
  1250.      (calling rest_of_compilation for each function).  */
  1251.  
  1252.   if (setjmp (toplevel) == 0)
  1253.     {
  1254.       if (yyparse () != 0)
  1255.     {
  1256.       if (errorcount == 0)
  1257.         {
  1258.           fprintf (stderr, "Errors detected in input file (your bison.simple is out of date)");
  1259.           errorcount = 1;
  1260.         }
  1261.     }
  1262.  
  1263.       /* Compilation is now finished except for writing
  1264.      what's left of the symbol table output.  */
  1265.  
  1266.       parse_time += gettime () - start_time;
  1267.  
  1268.       parse_time -= integration_time;
  1269.       parse_time -= varconst_time;
  1270.     }
  1271.   else
  1272.     {
  1273.       /* Change by Bryan Boreham, Kewill, Sat Aug  5 19:05:44 1989.
  1274.      We'll be coming back later, so skip the finish.
  1275.      Modified by Michael Tiemann.  */
  1276.  
  1277.       /* Compilation is now finished except for now.  */
  1278.  
  1279.       parse_time += gettime () - start_time;
  1280.  
  1281.       parse_time -= integration_time;
  1282.       parse_time -= varconst_time;
  1283.  
  1284.       goto after_finish_compilation;
  1285.     }
  1286.  
  1287.   globals = getdecls ();
  1288.  
  1289.   /* Really define vars that have had only a tentative definition.
  1290.      Really output inline functions that must actually be callable
  1291.      and have not been output so far.  */
  1292.  
  1293.   {
  1294.     tree decl;
  1295.     for (decl = globals; decl; decl = TREE_CHAIN (decl))
  1296.       {
  1297.     if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
  1298.         && ! TREE_ASM_WRITTEN (decl))
  1299.       {
  1300.         /* Don't write out static consts, unless we needed
  1301.            to take their address for some reason.  */
  1302.         if (! TREE_READONLY (decl)
  1303.         || TREE_PUBLIC (decl)
  1304.         || TREE_ADDRESSABLE (decl)
  1305.         || TREE_ADDRESSABLE (DECL_NAME (decl)))
  1306.           rest_of_decl_compilation (decl, 0, 1, 1);
  1307.         /* Otherwise maybe mention them just for the debugger.  */
  1308. #ifdef DBX_DEBUGGING_INFO
  1309.         else if (DECL_INITIAL (decl) && write_symbols == DBX_DEBUG)
  1310.           TIMEVAR (varconst_time, dbxout_symbol (decl, 0));
  1311. #endif
  1312. #ifdef SDB_DEBUGGING_INFO
  1313.         else if (DECL_INITIAL (decl) && write_symbols == SDB_DEBUG)
  1314.           TIMEVAR (varconst_time, sdbout_symbol (decl, 0));
  1315. #endif
  1316.       }
  1317.     if (TREE_CODE (decl) == FUNCTION_DECL
  1318.         && ! TREE_ASM_WRITTEN (decl)
  1319.         && DECL_INITIAL (decl) != 0
  1320.         && (TREE_ADDRESSABLE (decl) || TREE_ADDRESSABLE (DECL_NAME (decl)))
  1321.         && ! TREE_EXTERNAL (decl))
  1322.       output_inline_function (decl);
  1323.  
  1324.     /* Warn about any function or variable
  1325.        declared static but not defined.  */
  1326.     if ((warn_unused || TREE_USED (decl) || TREE_USED (DECL_NAME (decl)))
  1327. /*        && TREE_CODE (decl) == FUNCTION_DECL  */
  1328.         && DECL_INITIAL (decl) == 0
  1329.         && TREE_EXTERNAL (decl)
  1330.         && ! TREE_PUBLIC (decl))
  1331.       warning_with_decl (decl, "`%s' declared `static' but never defined");
  1332.     /* Warn about static fns or vars defined but not used,
  1333.        but not about inline functions
  1334.        since unused inline statics is normal practice.  */
  1335.     if (warn_unused
  1336.         && (TREE_CODE (decl) == FUNCTION_DECL
  1337.         || TREE_CODE (decl) == VAR_DECL)
  1338.         && ! TREE_EXTERNAL (decl)
  1339.         && ! TREE_PUBLIC (decl)
  1340.         && ! TREE_USED (decl)
  1341.         && ! TREE_INLINE (decl)
  1342.         /* The TREE_USED bit for file-scope decls
  1343.            is kept in the identifier, to handle multiple
  1344.            external decls in different scopes.  */
  1345.         && ! TREE_USED (DECL_NAME (decl)))
  1346.       warning_with_decl (decl, "`%s' defined but not used");
  1347.       }
  1348.   }
  1349.  
  1350.   /* Do dbx symbols */
  1351. #ifdef DBX_DEBUGGING_INFO
  1352.   if (write_symbols == DBX_DEBUG)
  1353.     TIMEVAR (symout_time,
  1354.          {
  1355.            dbxout_tags (gettags ());
  1356.            dbxout_types (get_permanent_types ());
  1357.          });
  1358. #endif
  1359.  
  1360. #ifdef SDB_DEBUGGING_INFO
  1361.   if (write_symbols == SDB_DEBUG)
  1362.     TIMEVAR (symout_time,
  1363.          {
  1364.            sdbout_tags (gettags ());
  1365.            sdbout_types (get_permanent_types ());
  1366.          });
  1367. #endif
  1368.  
  1369. #if 0  /* This mode is discontinued */
  1370.   /* Do gdb symbols */
  1371.   if (write_symbols == GDB_DEBUG)
  1372.     TIMEVAR (symout_time,
  1373.          {
  1374.            struct stat statbuf;
  1375.            fstat (fileno (finput), &statbuf);
  1376.            symout_types (get_permanent_types ());
  1377.            symout_top_blocks (globals, gettags ());
  1378.            symout_finish (name, statbuf.st_ctime);
  1379.          });
  1380. #endif /* 0 */
  1381.  
  1382.   /* Output some stuff at end of file if nec.  */
  1383.  
  1384.   end_final (main_input_filename);
  1385.  
  1386. #ifdef ASM_FILE_END
  1387.   ASM_FILE_END (asm_out_file);
  1388. #endif
  1389.  
  1390.  after_finish_compilation:
  1391.  
  1392.   /* Close the dump files.  */
  1393.  
  1394.   if (rtl_dump)
  1395.     fclose (rtl_dump_file);
  1396.  
  1397.   if (jump_opt_dump)
  1398.     fclose (jump_opt_dump_file);
  1399.  
  1400.   if (cse_dump)
  1401.     fclose (cse_dump_file);
  1402.  
  1403.   if (loop_dump)
  1404.     fclose (loop_dump_file);
  1405.  
  1406.   if (flow_dump)
  1407.     fclose (flow_dump_file);
  1408.  
  1409.   if (combine_dump)
  1410.     {
  1411.       dump_combine_total_stats (combine_dump_file);
  1412.       fclose (combine_dump_file);
  1413.     }
  1414.  
  1415.   if (local_reg_dump)
  1416.     fclose (local_reg_dump_file);
  1417.  
  1418.   if (global_reg_dump)
  1419.     fclose (global_reg_dump_file);
  1420.  
  1421.   if (jump2_opt_dump)
  1422.     fclose (jump2_opt_dump_file);
  1423.  
  1424.   if (dbr_sched_dump)
  1425.     fclose (dbr_sched_dump_file);
  1426.  
  1427.   /* Close non-debugging input and output files.  Take special care to note
  1428.      whether fclose returns an error, since the pages might still be on the
  1429.      buffer chain while the file is open.  */
  1430.  
  1431.   fclose (finput);
  1432.   if (ferror (asm_out_file) != 0 || fclose (asm_out_file) != 0)
  1433.     fatal_io_error (asm_file_name);
  1434.  
  1435.   /* Print the times.  */
  1436.  
  1437.   if (! quiet_flag)
  1438.     {
  1439.       fprintf (stderr,"\n");
  1440.       print_time ("parse", parse_time);
  1441.       print_time ("integration", integration_time);
  1442.       print_time ("jump", jump_time);
  1443.       print_time ("cse", cse_time);
  1444.       print_time ("loop", loop_time);
  1445.       print_time ("flow", flow_time);
  1446.       print_time ("combine", combine_time);
  1447.       print_time ("local-alloc", local_alloc_time);
  1448.       print_time ("global-alloc", global_alloc_time);
  1449.       print_time ("shorten-branch", shorten_branch_time);
  1450.       print_time ("dbranch", dbr_sched_time);
  1451.       print_time ("final", final_time);
  1452.       print_time ("varconst", varconst_time);
  1453.       print_time ("symout", symout_time);
  1454.       print_time ("dump", dump_time);
  1455.     }
  1456. }
  1457.  
  1458. /* This is called from finish_decl (within yyparse)
  1459.    for each declaration of a function or variable.
  1460.    This does nothing for automatic variables.
  1461.    Otherwise, it sets up the RTL and outputs any assembler code
  1462.    (label definition, storage allocation and initialization).
  1463.  
  1464.    DECL is the declaration.  If ASMSPEC is nonzero, it specifies
  1465.    the assembler symbol name to be used.  TOP_LEVEL is nonzero
  1466.    if this declaration is not within a function.  */
  1467.  
  1468. void
  1469. rest_of_decl_compilation (decl, asmspec, top_level, at_end)
  1470.      tree decl;
  1471.      char *asmspec;
  1472.      int top_level;
  1473.      int at_end;
  1474. {
  1475.   /* Declarations of variables, and of functions defined elsewhere.  */
  1476.  
  1477.   if (TREE_STATIC (decl) || TREE_EXTERNAL (decl))
  1478.     TIMEVAR (varconst_time,
  1479.          {
  1480.            make_decl_rtl (decl, asmspec, top_level);
  1481.            /* Don't output anything
  1482.           when a tentative file-scope definition is seen.
  1483.           But at end of compilation, do output code for them.  */
  1484.            if (! (! at_end && top_level
  1485.               && (DECL_INITIAL (decl) == 0
  1486.               || DECL_INITIAL (decl) == error_mark_node)))
  1487.          assemble_variable (decl, top_level, write_symbols, at_end);
  1488.          });
  1489.   else if (TREE_REGDECL (decl) && asmspec != 0)
  1490.     {
  1491.       if (decode_reg_name (asmspec) >= 0)
  1492.     {
  1493.       if (TREE_CODE (decl) == PARM_DECL)
  1494.         error ("parameter cannot have special register declaration");
  1495.       else
  1496.         {
  1497.           DECL_RTL (decl) = 0;
  1498.           make_decl_rtl (decl, asmspec, top_level);
  1499.         }
  1500.     }
  1501.       else
  1502.     error ("invalid register name `%s' for register variable", asmspec);
  1503.     }
  1504. #ifdef DBX_DEBUGGING_INFO
  1505.   else if (write_symbols == DBX_DEBUG && TREE_CODE (decl) == TYPE_DECL)
  1506.     TIMEVAR (varconst_time, dbxout_symbol (decl, 0));
  1507. #endif
  1508. #ifdef SDB_DEBUGGING_INFO
  1509.   else if (write_symbols == SDB_DEBUG && TREE_CODE (decl) == TYPE_DECL)
  1510.     TIMEVAR (varconst_time, sdbout_symbol (decl, 0));
  1511. #endif
  1512.  
  1513.   if (top_level)
  1514.     {
  1515. #if 0  /* This mode is discontinued */
  1516.       if (write_symbols == GDB_DEBUG)
  1517.     {
  1518.       TIMEVAR (symout_time,
  1519.            {
  1520.              /* The initizations make types when they contain
  1521.             string constants.  The types are on the temporary
  1522.             obstack, so output them now before they go away.  */
  1523.              symout_types (get_temporary_types ());
  1524.            });
  1525.     }
  1526.       else
  1527. #endif /* 0 */
  1528.     /* Clean out the temporary type list, since the types will go away.  */
  1529.     get_temporary_types ();
  1530.     }
  1531. }
  1532.  
  1533. /* This is called from finish_function (within yyparse)
  1534.    after each top-level definition is parsed.
  1535.    It is supposed to compile that function or variable
  1536.    and output the assembler code for it.
  1537.    After we return, the tree storage is freed.  */
  1538.  
  1539. void
  1540. rest_of_compilation (decl)
  1541.      tree decl;
  1542. {
  1543.   register rtx insns;
  1544.   int start_time = gettime ();
  1545.   int tem;
  1546.  
  1547.   /* If we are reconsidering an inline function
  1548.      at the end of compilation, skip the stuff for making it inline.  */
  1549.  
  1550.   if (DECL_SAVED_INSNS (decl) == 0)
  1551.     {
  1552.  
  1553.       /* If requested, consider whether to make this function inline.  */
  1554.       if (flag_inline_functions || TREE_INLINE (decl))
  1555.     {
  1556.       TIMEVAR (integration_time,
  1557.            {
  1558.              int specd = TREE_INLINE (decl);
  1559.              char *lose = function_cannot_inline_p (decl);
  1560.              if (lose != 0 && specd)
  1561.                warning_with_decl (decl, lose);
  1562.              if (lose == 0)
  1563.                save_for_inline (decl);
  1564.              else
  1565.                TREE_INLINE (decl) = 0;
  1566.            });
  1567.     }
  1568.  
  1569.       insns = get_insns ();
  1570.  
  1571.       /* Dump the rtl code if we are dumping rtl.  */
  1572.  
  1573.       if (rtl_dump)
  1574.     TIMEVAR (dump_time,
  1575.          {
  1576.            fprintf (rtl_dump_file, "\n;; Function %s\n\n",
  1577.                 IDENTIFIER_POINTER (DECL_NAME (decl)));
  1578.            if (DECL_SAVED_INSNS (decl))
  1579.              fprintf (rtl_dump_file, ";; (integrable)\n\n");
  1580.            print_rtl (rtl_dump_file, insns);
  1581.            fflush (rtl_dump_file);
  1582.          });
  1583.  
  1584.       /* If function is inline, and we don't yet know whether to
  1585.      compile it by itself, defer decision till end of compilation.
  1586.      finish_compilation will call rest_of_compilation again
  1587.      for those functions that need to be output.  */
  1588.  
  1589.       if (((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl)
  1590.         && ! flag_keep_inline_functions)
  1591.        || TREE_EXTERNAL (decl))
  1592.       && TREE_INLINE (decl))
  1593.     goto exit_rest_of_compilation;
  1594.     }
  1595.  
  1596.   TREE_ASM_WRITTEN (decl) = 1;
  1597.  
  1598.   if (rtl_dump_and_exit || flag_syntax_only)
  1599.     {
  1600.       get_temporary_types ();
  1601.       goto exit_rest_of_compilation;
  1602.     }
  1603.  
  1604.   insns = get_insns ();
  1605.  
  1606.   /* Copy any shared structure that should not be shared.  */
  1607.  
  1608.   unshare_all_rtl (insns);
  1609.  
  1610.   /* See if we have allocated stack slots that are not directly addressable.
  1611.      If so, scan all the insns and create explicit address computation
  1612.      for all references to such slots.  */
  1613. /*   fixup_stack_slots (); */
  1614.  
  1615.   /* Do jump optimization the first time, if -opt.
  1616.      Also do it if -W, but in that case it doesn't change the rtl code,
  1617.      it only computes whether control can drop off the end of the function.  */
  1618.  
  1619.   if (optimize || extra_warnings || warn_return_type
  1620.       /* If function is `volatile', we should warn if it tries to return.  */
  1621.       || TREE_THIS_VOLATILE (decl))
  1622.     TIMEVAR (jump_time, jump_optimize (insns, 0, 0));
  1623.  
  1624.   /* Dump rtl code after jump, if we are doing that.  */
  1625.  
  1626.   if (jump_opt_dump)
  1627.     TIMEVAR (dump_time,
  1628.          {
  1629.            fprintf (jump_opt_dump_file, "\n;; Function %s\n\n",
  1630.             IDENTIFIER_POINTER (DECL_NAME (decl)));
  1631.            print_rtl (jump_opt_dump_file, insns);
  1632.            fflush (jump_opt_dump_file);
  1633.          });
  1634.  
  1635.   /* Perform common subexpression elimination.
  1636.      Nonzero value from `cse_main' means that jumps were simplified
  1637.      and some code may now be unreachable, so do
  1638.      jump optimization again.  */
  1639.  
  1640.   if (cse_dump)
  1641.     TIMEVAR (dump_time,
  1642.          {
  1643.            fprintf (cse_dump_file, "\n;; Function %s\n\n",
  1644.             IDENTIFIER_POINTER (DECL_NAME (decl)));
  1645.          });
  1646.  
  1647.   if (optimize)
  1648.     {
  1649.       TIMEVAR (cse_time, reg_scan (insns, max_reg_num (), 0));
  1650.  
  1651.       TIMEVAR (cse_time, tem = cse_main (insns, max_reg_num (), cse_dump_file));
  1652.  
  1653.       if (tem)
  1654.     TIMEVAR (jump_time, jump_optimize (insns, 0, 0));
  1655.     }
  1656.  
  1657.   /* Dump rtl code after cse, if we are doing that.  */
  1658.  
  1659.   if (cse_dump)
  1660.     TIMEVAR (dump_time,
  1661.          {
  1662.            print_rtl (cse_dump_file, insns);
  1663.            fflush (cse_dump_file);
  1664.          });
  1665.  
  1666.   if (loop_dump)
  1667.     TIMEVAR (dump_time,
  1668.          {
  1669.            fprintf (loop_dump_file, "\n;; Function %s\n\n",
  1670.             IDENTIFIER_POINTER (DECL_NAME (decl)));
  1671.          });
  1672.  
  1673.   /* Move constant computations out of loops.  */
  1674.  
  1675.   if (optimize)
  1676.     {
  1677.       TIMEVAR (loop_time,
  1678.            {
  1679.          reg_scan (insns, max_reg_num (), 1);
  1680.          loop_optimize (insns, loop_dump ? loop_dump_file : 0);
  1681.            });
  1682.     }
  1683.  
  1684.   /* Dump rtl code after loop opt, if we are doing that.  */
  1685.  
  1686.   if (loop_dump)
  1687.     TIMEVAR (dump_time,
  1688.          {
  1689.            print_rtl (loop_dump_file, insns);
  1690.            fflush (loop_dump_file);
  1691.          });
  1692.  
  1693.   /* Now we choose between stupid (pcc-like) register allocation
  1694.      (if we got the -noreg switch and not -opt)
  1695.      and smart register allocation.  */
  1696.  
  1697.   if (optimize)            /* Stupid allocation probably won't work */
  1698.     obey_regdecls = 0;        /* if optimizations being done.  */
  1699.  
  1700.   regclass_init ();
  1701.  
  1702.   /* Print function header into flow dump now
  1703.      because doing the flow analysis makes some of the dump.  */
  1704.  
  1705.   if (flow_dump)
  1706.     TIMEVAR (dump_time,
  1707.          {
  1708.            fprintf (flow_dump_file, "\n;; Function %s\n\n",
  1709.             IDENTIFIER_POINTER (DECL_NAME (decl)));
  1710.          });
  1711.  
  1712.   if (obey_regdecls)
  1713.     {
  1714.       TIMEVAR (flow_time,
  1715.            {
  1716.          regclass (insns, max_reg_num ());
  1717.          stupid_life_analysis (insns, max_reg_num (),
  1718.                        flow_dump_file);
  1719.            });
  1720.     }
  1721.   else
  1722.     {
  1723.       /* Do control and data flow analysis,
  1724.      and write some of the results to dump file.  */
  1725.  
  1726.       TIMEVAR (flow_time, flow_analysis (insns, max_reg_num (),
  1727.                      flow_dump_file));
  1728.       if (extra_warnings)
  1729.     uninitialized_vars_warning (DECL_INITIAL (decl));
  1730.     }
  1731.  
  1732.   /* Dump rtl after flow analysis.  */
  1733.  
  1734.   if (flow_dump)
  1735.     TIMEVAR (dump_time,
  1736.          {
  1737.            print_rtl (flow_dump_file, insns);
  1738.            fflush (flow_dump_file);
  1739.          });
  1740.  
  1741.   /* If -opt, try combining insns through substitution.  */
  1742.  
  1743.   if (optimize)
  1744.     TIMEVAR (combine_time, combine_instructions (insns, max_reg_num ()));
  1745.  
  1746.   /* Dump rtl code after insn combination.  */
  1747.  
  1748.   if (combine_dump)
  1749.     TIMEVAR (dump_time,
  1750.          {
  1751.            fprintf (combine_dump_file, "\n;; Function %s\n\n",
  1752.             IDENTIFIER_POINTER (DECL_NAME (decl)));
  1753.            dump_combine_stats (combine_dump_file);
  1754.            print_rtl (combine_dump_file, insns);
  1755.            fflush (combine_dump_file);
  1756.          });
  1757.  
  1758.   /* Unless we did stupid register allocation,
  1759.      allocate pseudo-regs that are used only within 1 basic block.  */
  1760.  
  1761.   if (!obey_regdecls)
  1762.     TIMEVAR (local_alloc_time,
  1763.          {
  1764.            regclass (insns, max_reg_num ());
  1765.            local_alloc ();
  1766.          });
  1767.  
  1768.   /* Dump rtl code after allocating regs within basic blocks.  */
  1769.  
  1770.   if (local_reg_dump)
  1771.     TIMEVAR (dump_time,
  1772.          {
  1773.            fprintf (local_reg_dump_file, "\n;; Function %s\n\n",
  1774.             IDENTIFIER_POINTER (DECL_NAME (decl)));
  1775.            dump_flow_info (local_reg_dump_file);
  1776.            dump_local_alloc (local_reg_dump_file);
  1777.            print_rtl (local_reg_dump_file, insns);
  1778.            fflush (local_reg_dump_file);
  1779.          });
  1780.  
  1781.   if (global_reg_dump)
  1782.     TIMEVAR (dump_time,
  1783.          fprintf (global_reg_dump_file, "\n;; Function %s\n\n",
  1784.               IDENTIFIER_POINTER (DECL_NAME (decl))));
  1785.  
  1786.   /* Unless we did stupid register allocation,
  1787.      allocate remaining pseudo-regs, then do the reload pass
  1788.      fixing up any insns that are invalid.  */
  1789.  
  1790.   TIMEVAR (global_alloc_time,
  1791.        {
  1792.          if (!obey_regdecls)
  1793.            global_alloc (global_reg_dump ? global_reg_dump_file : 0);
  1794.          else
  1795.            reload (insns, 0,
  1796.                global_reg_dump ? global_reg_dump_file : 0);
  1797.        });
  1798.  
  1799.   if (global_reg_dump)
  1800.     TIMEVAR (dump_time,
  1801.          {
  1802.            dump_global_regs (global_reg_dump_file);
  1803.            print_rtl (global_reg_dump_file, insns);
  1804.            fflush (global_reg_dump_file);
  1805.          });
  1806.  
  1807.   rtx_equal_function_value_matters = 1;
  1808.   reload_completed = 1;
  1809.  
  1810.   /* One more attempt to remove jumps to .+1
  1811.      left by dead-store-elimination.
  1812.      Also do cross-jumping this time
  1813.      and delete no-op move insns.  */
  1814.  
  1815.   if (optimize)
  1816.     {
  1817.       TIMEVAR (jump_time, jump_optimize (insns, 1, 1));
  1818.     }
  1819.  
  1820.   /* Dump rtl code after jump, if we are doing that.  */
  1821.  
  1822.   if (jump2_opt_dump)
  1823.     TIMEVAR (dump_time,
  1824.          {
  1825.            fprintf (jump2_opt_dump_file, "\n;; Function %s\n\n",
  1826.             IDENTIFIER_POINTER (DECL_NAME (decl)));
  1827.            print_rtl (jump2_opt_dump_file, insns);
  1828.            fflush (jump2_opt_dump_file);
  1829.          });
  1830.  
  1831.   /* If a scheduling pass for delayed branches is to be done,
  1832.      call the scheduling code. */
  1833.  
  1834. #ifdef HAVE_DELAYED_BRANCH
  1835.   if (optimize && flag_delayed_branch)
  1836.     {
  1837.       TIMEVAR (dbr_sched_time, dbr_schedule (insns, dbr_sched_dump_file));
  1838.       if (dbr_sched_dump)
  1839.     {
  1840.       TIMEVAR (dump_time,
  1841.          {
  1842.            fprintf (dbr_sched_dump_file, "\n;; Function %s\n\n",
  1843.                 IDENTIFIER_POINTER (DECL_NAME (decl)));
  1844.            print_rtl (dbr_sched_dump_file, insns);
  1845.            fflush (dbr_sched_dump_file);
  1846.          });
  1847.     }
  1848.     }
  1849. #endif
  1850.  
  1851. #if 0
  1852.   if (optimize)
  1853.     /* Shorten branches.  */
  1854.     TIMEVAR (shorten_branch_time,
  1855.          {
  1856.            shorten_branches (get_insns ());
  1857.          });
  1858. #endif
  1859.  
  1860.   /* Now turn the rtl into assembler code.  */
  1861.  
  1862.   TIMEVAR (final_time,
  1863.        {
  1864.          assemble_function (decl);
  1865.          final_start_function (insns, asm_out_file,
  1866.                    write_symbols, optimize);
  1867.          final (insns, asm_out_file,
  1868.             write_symbols, optimize, 0);
  1869.          final_end_function (insns, asm_out_file,
  1870.                  write_symbols, optimize);
  1871.          fflush (asm_out_file);
  1872.        });
  1873.  
  1874. #if 0  /* This mode is discontinued */
  1875.   /* Write GDB symbols if requested */
  1876.  
  1877.   if (write_symbols == GDB_DEBUG)
  1878.     {
  1879.       TIMEVAR (symout_time,
  1880.            {
  1881.          symout_types (get_permanent_types ());
  1882.          symout_types (get_temporary_types ());
  1883.  
  1884.          DECL_BLOCK_SYMTAB_ADDRESS (decl)
  1885.            = symout_function (DECL_INITIAL (decl),
  1886.                       DECL_ARGUMENTS (decl), 0);
  1887.          symout_function_end ();
  1888.            });
  1889.     }
  1890.   else
  1891. #endif /* 0 */
  1892.     get_temporary_types ();
  1893.  
  1894.   /* Write DBX symbols if requested */
  1895.  
  1896. #ifdef DBX_DEBUGGING_INFO
  1897.   if (write_symbols == DBX_DEBUG)
  1898.     TIMEVAR (symout_time, dbxout_function (decl));
  1899. #endif
  1900.  
  1901.  exit_rest_of_compilation:
  1902.  
  1903.   rtx_equal_function_value_matters = 0;
  1904.   reload_completed = 0;
  1905.  
  1906.   /* Clear out the real_constant_chain before some of the rtx's
  1907.      it runs through become garbage.  */
  1908.  
  1909.   clear_const_double_mem ();
  1910.  
  1911.   /* The parsing time is all the time spent in yyparse
  1912.      *except* what is spent in this function.  */
  1913.  
  1914.   parse_time -= gettime () - start_time;
  1915. }
  1916.  
  1917. /* Hacky routine to read back entire data segment saved earlier. 
  1918.    Bryan Boreham (bryan@kewill.uucp)    */
  1919.  
  1920. void undump_data (name)
  1921.      char *name;
  1922. {
  1923.   int file;
  1924.   long file_size;
  1925.   extern int my_edata;
  1926.   char buf[256] = "/usr/local/lib/";
  1927.  
  1928.   strcat (buf, name);
  1929.  
  1930.   if ((file = open(name, O_RDONLY)) == -1)
  1931.     if ((file = open(buf, O_RDONLY)) == -1)
  1932.       {
  1933.     perror(name);
  1934.     return;
  1935.       }
  1936.   file_size = lseek(file, 0L, SEEK_END);
  1937.   lseek(file, 0L, SEEK_SET);
  1938.   brk((char*)(&my_edata) + file_size);
  1939.   if (read (file, &my_edata, file_size) != file_size)
  1940.     perror(name);
  1941. }
  1942.  
  1943. /* Entry point of c++.  Decode command args, then call compile_file.
  1944.    Exit code is 35 if can't open files, 34 if fatal error,
  1945.    33 if had nonfatal errors, else success.  */
  1946.  
  1947. int
  1948. main (argc, argv, envp)
  1949.      int argc;
  1950.      char **argv;
  1951.      char **envp;
  1952. {
  1953.   register int i;
  1954.   char *filename = 0;
  1955.   int print_mem_flag = 0;
  1956.   char *p;
  1957.  
  1958.   /* save in case md file wants to emit args as a comment.  */
  1959.   save_argc = argc;
  1960.   save_argv = argv;
  1961.  
  1962.   p = argv[0] + strlen (argv[0]);
  1963.   while (p != argv[0] && p[-1] != '/') --p;
  1964.   progname = p;
  1965.  
  1966.   /* Change by Bryan Boreham, Kewill, Sun Aug  6 13:42:47 1989.
  1967.      Stuff for unexec'ing    */
  1968.   dump_source_name = argv[0];
  1969.   asm_file_name = (char*) 0;
  1970.   
  1971. #ifdef RLIMIT_STACK
  1972.   /* Get rid of any avoidable limit on stack size.  */
  1973.   {
  1974.     struct rlimit rlim;
  1975.  
  1976.     /* Set the stack limit huge so that alloca does not fail. */
  1977.     getrlimit (RLIMIT_STACK, &rlim);
  1978.     rlim.rlim_cur = rlim.rlim_max;
  1979.     setrlimit (RLIMIT_STACK, &rlim);
  1980.   }
  1981. #endif /* RLIMIT_STACK */
  1982.  
  1983.   signal (SIGFPE, float_signal);
  1984.  
  1985.   signal (SIGPIPE, pipe_closed);
  1986.  
  1987.   decl_printable_name = decl_name;
  1988.   lang_expand_expr = fancy_abort;
  1989.  
  1990.   /* Initialize whether `char' is signed.  */
  1991.   flag_signed_char = DEFAULT_SIGNED_CHAR;
  1992. #ifdef DEFAULT_SHORT_ENUMS
  1993.   /* Initialize how much space enums occupy, by default.  */
  1994.   flag_short_enums = DEFAULT_SHORT_ENUMS;
  1995. #endif
  1996.  
  1997.   /* This is zeroed by -O.  */
  1998.   obey_regdecls = 1;
  1999.  
  2000.   /* Initialize register usage now so switches may override.  */
  2001.   init_reg_sets ();
  2002.  
  2003.   target_flags = 0;
  2004.   set_target_switch ("");
  2005.  
  2006.   for (i = 1; i < argc; i++)
  2007.     if (argv[i][0] == '-' && argv[i][1] != 0)
  2008.       {
  2009.     register char *str = argv[i] + 1;
  2010.     if (str[0] == 'Y')
  2011.       str++;
  2012.  
  2013.     if (str[0] == 'm')
  2014.       set_target_switch (&str[1]);
  2015.     else if (!strcmp (str, "dumpbase"))
  2016.       {
  2017.         dump_base_name = argv[++i];
  2018.       }
  2019.     else if (str[0] == 'd')
  2020.       {
  2021.         register char *p = &str[1];
  2022.         while (*p)
  2023.           switch (*p++)
  2024.         {
  2025.         case 'c':
  2026.           combine_dump = 1;
  2027.           break;
  2028.         case 'd':
  2029.           dbr_sched_dump = 1;
  2030.           break;
  2031.         case 'f':
  2032.           flow_dump = 1;
  2033.           break;
  2034.         case 'g':
  2035.           global_reg_dump = 1;
  2036.           break;
  2037.         case 'j':
  2038.           jump_opt_dump = 1;
  2039.           break;
  2040.         case 'J':
  2041.           jump2_opt_dump = 1;
  2042.           break;
  2043.         case 'l':
  2044.           local_reg_dump = 1;
  2045.           break;
  2046.         case 'L':
  2047.           loop_dump = 1;
  2048.           break;
  2049.         case 'm':
  2050.           print_mem_flag = 1;
  2051.           break;
  2052.         case 'r':
  2053.           rtl_dump = 1;
  2054.           break;
  2055.         case 's':
  2056.           cse_dump = 1;
  2057.           break;
  2058.         case 'y':
  2059.           yydebug = 1;
  2060.           break;
  2061.         case 'x':
  2062.           rtl_dump_and_exit = 1;
  2063.           break;
  2064.         }
  2065.       }
  2066.     else if (str[0] == 'f')
  2067.       {
  2068.         int j;
  2069.         register char *p = &str[1];
  2070.         int found = 0;
  2071.  
  2072.         /* Some kind of -f option.
  2073.            P's value is the option sans `-f'.
  2074.            Search for it in the table of options.  */
  2075.  
  2076.         for (j = 0;
  2077.          !found && j < sizeof (f_options) / sizeof (f_options[0]);
  2078.          j++)
  2079.           {
  2080.         if (!strcmp (p, f_options[j].string))
  2081.           {
  2082.             *f_options[j].variable = f_options[j].on_value;
  2083.             /* A goto here would be cleaner,
  2084.                but breaks the vax pcc.  */
  2085.             found = 1;
  2086.           }
  2087.         if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
  2088.             && ! strcmp (p+3, f_options[j].string))
  2089.           {
  2090.             *f_options[j].variable = ! f_options[j].on_value;
  2091.             found = 1;
  2092.           }
  2093.           }
  2094.  
  2095.         if (found)
  2096.           ;
  2097.         else if (!strncmp (p, "undump-", 7))
  2098.           undump_data (&p[7]);
  2099.         else if (!strncmp (p, "fixed-", 6))
  2100.           fix_register (&p[6], 1, 1);
  2101.         else if (!strncmp (p, "call-used-", 10))
  2102.           fix_register (&p[10], 0, 1);
  2103.         else if (!strncmp (p, "call-saved-", 11))
  2104.           fix_register (&p[11], 0, 0);
  2105.         else if (! lang_decode_option (argv[i]))
  2106.           error ("Invalid option `%s'", argv[i]);
  2107.       }
  2108.     else if (!strcmp (str, "noreg"))
  2109.       ;
  2110.     else if (!strcmp (str, "opt"))
  2111.       optimize = 1, obey_regdecls = 0;
  2112.     else if (!strcmp (str, "O"))
  2113.       optimize = 1, obey_regdecls = 0;
  2114.     else if (!strcmp (str, "pedantic"))
  2115.       pedantic = 1;
  2116.     else if (lang_decode_option (argv[i]))
  2117.       ;
  2118.     else if (!strcmp (str, "quiet"))
  2119.       quiet_flag = 1;
  2120.     else if (!strcmp (str, "version"))
  2121.       {
  2122.         extern char *version_string, *language_string;
  2123.         fprintf (stderr, "%s version %s", language_string, version_string);
  2124. #ifdef TARGET_VERSION
  2125.         TARGET_VERSION;
  2126. #endif
  2127. #ifdef __GNUC__
  2128. #ifndef __VERSION__
  2129. #define __VERSION__ "[unknown]"
  2130. #endif
  2131.         fprintf (stderr, " compiled by GNU C version %s.\n", __VERSION__);
  2132. #else
  2133.         fprintf (stderr, " compiled by CC.\n");
  2134. #endif
  2135.         print_target_switch_defaults ();
  2136.       }
  2137.     else if (!strcmp (str, "w"))
  2138.       inhibit_warnings = 1;
  2139.     else if (!strcmp (str, "W"))
  2140.       extra_warnings = 1;
  2141.     else if (!strcmp (str, "Wunused"))
  2142.       warn_unused = 1;
  2143.     else if (!strcmp (str, "Wshadow"))
  2144.       warn_shadow = 1;
  2145.     else if (!strcmp (str, "Wswitch"))
  2146.       warn_switch = 1;
  2147.     else if (!strcmp (str, "Wconversion"))
  2148.       warn_conversion = 1;
  2149.     else if (!strncmp (str, "Wid-clash-", 10))
  2150.       {
  2151.         char *endp = str + 10;
  2152.  
  2153.         while (*endp)
  2154.           {
  2155.         if (*endp >= '0' && *endp <= '9')
  2156.           endp++;
  2157.         else
  2158.           error ("Invalid option `%s'", argv[i]);
  2159.           }
  2160.         warn_id_clash = 1;
  2161.         id_clash_len = atoi (str + 10);
  2162.       }
  2163.     else if (!strcmp (str, "p"))
  2164.       profile_flag = 1;
  2165.     else if (!strcmp (str, "a"))
  2166.       {
  2167. #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
  2168.         warning ("`-a' option (basic block profile) not supported");
  2169. #else
  2170.         profile_block_flag = 1;
  2171. #endif
  2172.       }
  2173. #ifdef 0
  2174.     else if (!strcmp (str, "gg"))
  2175.       write_symbols = GDB_DEBUG;
  2176. #endif
  2177. #ifdef DBX_DEBUGGING_INFO
  2178.     else if (!strcmp (str, "g0"))
  2179.       write_symbols = DBX_DEBUG;
  2180.     else if (!strcmp (str, "G0"))
  2181.       write_symbols = DBX_DEBUG;
  2182. #ifdef SDB_DEBUGGING_INFO
  2183.     else if (!strcmp (str, "gsdb"))
  2184.       write_symbols = SDB_DEBUG;
  2185. #endif
  2186.     else if (!strcmp (str, "g"))
  2187.       {
  2188.         write_symbols = DBX_DEBUG;
  2189.         use_gdb_dbx_extensions = 1;
  2190.       }
  2191.     else if (!strcmp (str, "G"))
  2192.       {
  2193.         write_symbols = DBX_DEBUG;
  2194.         use_gdb_dbx_extensions = 1;
  2195.       }
  2196. #endif /* DBX_DEBUGGING_INFO */
  2197. #ifdef SDB_DEBUGGING_INFO
  2198.     else if (!strcmp (str, "g"))
  2199.       write_symbols = SDB_DEBUG;
  2200.     else if (!strcmp (str, "G"))
  2201.       write_symbols = SDB_DEBUG;
  2202.     else if (!strcmp (str, "g0"))
  2203.       write_symbols = SDB_DEBUG;
  2204.     else if (!strcmp (str, "G0"))
  2205.       write_symbols = SDB_DEBUG;
  2206.     else if (!strcmp (str, "gsdb"))
  2207.       write_symbols = SDB_DEBUG;
  2208. #endif /* SDB_DEBUGGING_INFO */
  2209. #if 0
  2210.     else if (!strcmp (str, "symout"))
  2211.       {
  2212.         if (write_symbols == NO_DEBUG)
  2213.           write_symbols = GDB_DEBUG;
  2214.         sym_file_name = argv[++i];
  2215.       }
  2216. #endif /* 0 */
  2217.     else if (!strcmp (str, "o"))
  2218.       {
  2219.         asm_file_name = argv[++i];
  2220.       }
  2221.     else
  2222.       error ("Invalid option `%s'", argv[i]);
  2223.       }
  2224.   else if (argv[i][0] == '+')
  2225.     {
  2226.       if (lang_decode_option (argv[i]))
  2227.     ;
  2228.       else
  2229.     error ("Invalid option `%s'", argv[i]);
  2230.     }
  2231.   else
  2232.     filename = argv[i];
  2233.  
  2234. #ifdef OVERRIDE_OPTIONS
  2235.   /* Some machines may reject certain combinations of options.  */
  2236.   OVERRIDE_OPTIONS;
  2237. #endif
  2238.  
  2239.   /* Now that register usage is specified, convert it to HARD_REG_SETs.  */
  2240.   init_reg_sets_1 ();
  2241.  
  2242.   compile_file (filename);
  2243.  
  2244. #ifndef USG
  2245. #ifndef VMS
  2246.   if (print_mem_flag)
  2247.     {
  2248.       extern char **environ;
  2249.       char *lim = (char *) sbrk (0);
  2250.  
  2251.       fprintf (stderr, "Data size %d.\n",
  2252.            (int) lim - (int) &environ);
  2253.       fflush (stderr);
  2254.  
  2255.       system ("ps v");
  2256.     }
  2257. #endif /* not VMS */
  2258. #endif /* not USG */
  2259.  
  2260.   if (errorcount)
  2261.     exit (FATAL_EXIT_CODE);
  2262.   if (sorrycount)
  2263.     exit (FATAL_EXIT_CODE);
  2264.   exit (SUCCESS_EXIT_CODE);
  2265.   return 34;
  2266. }
  2267.  
  2268. /* Decode -m switches.  */
  2269.  
  2270. /* Here is a table, controlled by the tm-...h file, listing each -m switch
  2271.    and which bits in `target_switches' it should set or clear.
  2272.    If VALUE is positive, it is bits to set.
  2273.    If VALUE is negative, -VALUE is bits to clear.
  2274.    (The sign bit is not used so there is no confusion.)  */
  2275.  
  2276. struct {char *name; int value;} target_switches []
  2277.   = TARGET_SWITCHES;
  2278.  
  2279. /* Decode the switch -mNAME.  */
  2280.  
  2281. void
  2282. set_target_switch (name)
  2283.      char *name;
  2284. {
  2285.   register int j;
  2286.   int valid = 0;
  2287.  
  2288.   for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
  2289.     if (!strcmp (target_switches[j].name, name))
  2290.       {
  2291.     if (target_switches[j].value < 0)
  2292.       target_flags &= ~-target_switches[j].value;
  2293.     else
  2294.       target_flags |= target_switches[j].value;
  2295.     valid = 1;
  2296.       }
  2297.  
  2298.   if (!valid)
  2299.     error ("Invalid option `%s'", name);
  2300. }
  2301.  
  2302. /* Print default target switches for -version.  */
  2303.  
  2304. void
  2305. print_target_switch_defaults ()
  2306. {
  2307.   register int j;
  2308.   register int mask = TARGET_DEFAULT;
  2309.  
  2310.   fprintf (stderr, "default target switches:");
  2311.   for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
  2312.     if (target_switches[j].name[0] != '\0'
  2313.     && target_switches[j].value > 0
  2314.     && (target_switches[j].value & mask) == target_switches[j].value)
  2315.       fprintf (stderr, " -m%s", target_switches[j].name);
  2316.  
  2317.   fprintf (stderr, "\n");
  2318. }
  2319.